cmake_minimum_required(VERSION 3.16)

project(libcmpltrtok)

enable_language(C)
enable_language(CXX)

add_compile_definitions(_GNU_SOURCE)

add_library(
	cmpltrtok
	SHARED
	log.c
	math.c
	other.c
	params_dict.c
	path.c
	path.cpp
	pointer.c
	string.c
	string.cpp
	time.c
)

add_custom_target(test)
add_dependencies(
	test
	test_path_cpp.out
	test_path_funcs.out
	test_path_funcs.cpp.out
	test_rand_perm.out
	test_string_cpp.out
	test_string_funcs.out
	test_time.out
)

add_executable(
	test_path_cpp.out
	EXCLUDE_FROM_ALL
	test_path_cpp.c
)

target_link_libraries(
	test_path_cpp.out
	PRIVATE cmpltrtok
)

add_executable(
	test_path_funcs.out
	EXCLUDE_FROM_ALL
	test_path_funcs.c
)

target_link_libraries(
	test_path_funcs.out
	PRIVATE cmpltrtok
)

add_executable(
	test_path_funcs.cpp.out
	EXCLUDE_FROM_ALL
	test_path_funcs.cpp
)

target_link_libraries(
	test_path_funcs.cpp.out
	PRIVATE cmpltrtok
)

add_executable(
	test_path_join_many.out
	EXCLUDE_FROM_ALL
	test_path_join_many.c
)

target_link_libraries(
	test_path_join_many.out
	PRIVATE cmpltrtok ffcall
)

add_executable(
	test_rand_perm.out
	EXCLUDE_FROM_ALL
	test_rand_perm.c
)

target_link_libraries(
	test_rand_perm.out
	PRIVATE cmpltrtok
)

add_executable(
	test_string_cpp.out
	EXCLUDE_FROM_ALL
	test_string_cpp.c
)

target_link_libraries(
	test_string_cpp.out
	PRIVATE cmpltrtok
)

add_executable(
	test_string_funcs.out
	EXCLUDE_FROM_ALL
	test_string_funcs.c
)

target_link_libraries(
	test_string_funcs.out
	PRIVATE cmpltrtok
)

add_executable(
	test_time.out
	EXCLUDE_FROM_ALL
	test_time.c
)

target_link_libraries(
	test_time.out
	PRIVATE cmpltrtok
)
